package com.itheima.socket.udp.demo01;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class SendDemo01 {

    public static void main(String[] args) throws IOException {

        DatagramSocket datagramSocket = new DatagramSocket();

        String s = "hello";
        byte[] bytes = s.getBytes("UTF-8");
        int length = bytes.length;
        InetAddress inetAddress = InetAddress.getByName("192.168.19.34");
        int port = 8888;
        DatagramPacket datagramPacket = new DatagramPacket(bytes, length, inetAddress, port);

        datagramSocket.send(datagramPacket);

        datagramSocket.close();
    }

}
